package secondBrush.hash;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.function.ToIntFunction;

public class E02Leetcode349 {

    public int[] intersection(int[] nums1, int[] nums2) {

        HashSet<Integer> set = new HashSet<>();
        HashSet<Integer> resultSet = new HashSet<>();

        for (int i : nums1) {
            set.add(i);
        }
        for (int item : nums2) {
            if (set.contains(item)) {
                resultSet.add(item);
            }
        }

        return resultSet.stream()
                .mapToInt(Integer::intValue).toArray();





    }
}
